<?php
$bottom_margin = $_MODULE[bottom_margin];
$bottom_color = $_MODULE[bottom_color];
if (!isset($bottom_margin)) $bottom_margin = 0;
if (!isset($bottom_color)) $bottom_color = "#FFFFFF";

$main_title_default = 'main title';
$sub_title_default='sub title';
$main_title_color_default='#FF7F00';
$sub_title_color_default='#FF7F00';

function getParam($paramName,$defaultValue){
    global $_MODULE;
    $value = $_MODULE[$paramName];
    if(empty($value)) return $defaultValue;
    return $value;
}

function myEcho($paramName,$defaultValue){
    echo getParam($paramName,$defaultValue);
}

function echoTitleColor($paramName){
    echo getParam($paramName,'#CDAA7D');
}

function echoMainTitle($paramName){
    echo getParam($paramName,'主标题1');
}

function echoSubTitle($paramName){
    echo getParam($paramName,'副标题1');
}

function getIsShow($paramName){
    $param =  getParam($paramName,null);
    if(empty($param)){
        return 'noShow';
    }
    return '';
}


function getLeftImageHtml($link_url_,$left_image_1,$left_image_0,$left_main_title,$left_sub_title,$left_main_title_color,$left_sub_title_color,$isShow){
return "
<td rowspan='2' style='padding-right: 15px;'>
    <a $link_url_ target='_blank' class='no_decoration'>
        <div class='positive_bg_img_left'
             style='background-image:url($left_image_1);'>
            <div class='title'>
                <p class='main_title'
                   style='color: $left_main_title_color;'>$left_main_title</p>
                <p class='sub_title'
                   style='color: $left_sub_title_color;'>$left_sub_title</p>
            </div>
            <div class='reverse_bg_img_left $isShow'
                 style='background-image:url($left_image_0);'>
                <div class='title'>
                    <p class='main_title'
                       style='color: $left_main_title_color;'>$left_main_title</p>
                    <p class='sub_title'
                       style='color: $left_sub_title_color;'>$left_sub_title</p>
                </div>
            </div>
            
        </div>
    </a>
</td>
";
}



function getCommonImageHtml($link_url_,$image_1,$image_0,$main_title,$sub_title,$main_title_color,$sub_title_color,$i,$marginTop,$isShow){
return "

            <td style='padding-right: 15px;padding-top: $marginTop;'>
                <a $link_url_ target='_blank' class='no_decoration'>
                    <div class='positive_bg_img_$i'
                         style='background-image:url($image_1);'>
                        <div class='title'>
                            <p class='main_title'
                               style='color: $main_title_color;'>$main_title</p>
                            <p class='sub_title'
                               style='color: $sub_title_color;'>$sub_title</p>
                        </div>
                        <div class='reverse_bg_img_$i $isShow'
                             style='background-image:url($image_0);'>
                            <div class='title'>
                                <p class='main_title'
                                   style='color: $main_title_color;'>$main_title</p>
                                <p class='sub_title'
                                   style='color: $sub_title_color;'>$sub_title</p>
                            </div>
                        </div>
                    </div>
                </a>
            </td>
";
}

?>

<div class='module dshop-um-ggw3 module-thirdparty'
     style='margin-bottom:<? echo $bottom_margin; ?>px; background-color:<? echo $bottom_color; ?>;'>
    <table>
      <?php
        $NumberMap = array(0=>'one',1=>'two',2=>'three',3=>'four');
        $num = 0;
        for ($i = 0; $i < 2; $i++) {
            echo "<tr>";
            for ($j = 0; $j < 3; $j++) {
                if($i == 1 && $j == 0) continue;
                if($i==0 && $j==0){
                    echo getLeftImageHtml(getHref('left_link'),
                        getParam('left_image_1','assets/images/left_1.jpg'),
                        getParam('left_image_0','assets/images/left_0.jpg'),
                        getParam('left_main_title',$main_title_default),
                        getParam('left_sub_title',$sub_title_default),
                        getParam('left_main_title_color',$main_title_color_default),
                        getParam('left_sub_title_color',$sub_title_color_default),
                        getIsShow('left_image_0')
                    );
                }else{

                    echo getCommonImageHtml(getHref('right_'.$NumberMap[$num].'_link'),
                        getParam('right_'.$NumberMap[$num].'_image_1','assets/images/right_one_1.jpg'),
                        getParam('right_'.$NumberMap[$num].'_image_0','assets/images/right_one_0.png')
                        ,getParam('right_'.$NumberMap[$num].'_main_title',$main_title_default),
                        getParam('right_'.$NumberMap[$num].'_sub_title',$main_title_default),
                        getParam('right_'.$NumberMap[$num].'_main_title_color',$main_title_color_default),
                        getParam('right_'.$NumberMap[$num].'_sub_title_color',$sub_title_color_default),
                        $i,($i * 15).'px',getIsShow('right_'.$NumberMap[$num].'_image_0'));
                    $num ++;
                }
            }
            echo "</tr>";
        }
        ?>

    </table>
</div>
